<template>
    <Layout>
        <Form ref="form1" :model="dataToQuery" :label-width="120">
            <Row class="query-form">
                <Col span="8">
                    <FormItem label="单位名称：" prop="order">
                        <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyName'
                                      :orgTree="true"
                                      :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label='年份：'>
                        <DatePicker class="query-form-el" type="year" placeholder="请选择年份" v-model="dataToQuery.yearDate" :clearable="false"
                                    @on-change="()=>{if(dataToQuery.yearDate instanceof Date){dataToQuery.year = dataToQuery.yearDate.getFullYear().toString()}}"></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8" v-if="!switchFlag">
                    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
                <Col span="8" v-else>
                    <FormItem label="行动计划名称：" >
                        <Select v-model='dataToQuery.planName' label-in-value class='query-form-el'>
                            <Option v-for="item in dictMap.planNames" :value="item.codingCodeId" :key="item.codingCodeId">{{item.codingName }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">

                <Col span="8" offset="16">
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                    <Button size="large" class="ivu-btn-add" icon="md-add" @click="addInfo">新增</Button>
                    <download-button :api="exportUrl" :queryForm="dataToQuery" />
                    <!-- <Button type="primary" class="ivu-btn-add" icon="md-cloud-download" @click="exportFormSubmit">导出</Button> -->
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
               :loading='pageStatus.loading'
               border :columns="columns1" :data="dataTable">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>
        <Modal :title="this.getModalTitle('污染防治攻坚战')" :transfer=false :mask-closable="false" v-model="dialogShow"
               v-if="dataToView && dialogShow" :width=900 class-name='limit-height-dialog'>
            <Row>
                <Col span="24">
                    <Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':''" :show-message="false"
                          :model="dataToView" :rules="mode === 'view'?{}:ruleCustom"
                          :label-width="mode === 'view'?160:null" :label-position="mode === 'view'?'right':'top'">
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='所属二级集团：' prop='belongOrgId'>
                                    <div v-if="mode === 'view'">{{ dataToView.belongOrgName }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写所属二级集团" type='text' v-model='dataToView.belongOrgId'></Input>-->
                                    <Select v-else class='query-form-el' placeholder="集团名称"  v-model='dataToView.belongOrgId' label-in-value @on-change="belongChange">
                                        <Option v-for="item in twoLevel" :value="item.orgId" :key="item.orgId">{{item.orgName}}</Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='单位名称：' prop='companyId'>
                                    <div v-if="mode === 'view'">{{ dataToView.companyName }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写单位名称" type='text' v-model='dataToView.companyId'></Input>-->
                                    <div v-else>
                                        <cascader-dom  v-if="show"  class='query-form-el' ref='orgCascader' @setOrgInfo='setCompanyId' @setOrgname="setCompanyName" :orgTree="true"
                                                       :currentOrgId="dataToView.companyId" :rootOrgId="dataToView.belongOrgId"
                                                       :setCurrentName="{label:dataToView.companyName,value:dataToView.companyId}" ></cascader-dom>
                                    </div>
                                </FormItem>
                            </Col>
                        </Row>

                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='年份：' prop='yearDate'>
                                    <div v-if="mode === 'view'">{{ dataToView.year }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写年份" type='text' v-model='dataToView.year'></Input>-->
                                    <DatePicker v-else class="query-form-el" type="year" placeholder="请选择年份" v-model="dataToView.yearDate" :clearable="false"
                                                @on-change="()=>{if(dataToView.yearDate instanceof Date){dataToView.year = dataToView.yearDate.getFullYear().toString()}}"></DatePicker>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='行动计划名称：' prop='planName'>
                                    <div v-if="mode === 'view'">{{ dataToView.planNameDesc }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写行动计划名称" type='text' v-model='dataToView.planName'></Input>-->
                                    <Select v-else v-model='dataToView.planName' label-in-value class='query-form-el'>
                                        <Option v-for="item in dictMap.planNames" :value="item.codingCodeId" :key="item.codingCodeId">{{item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='重点任务：' prop='priority'>
                                    <div v-if="mode === 'view'">{{ dataToView.priority }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写重点任务" type='text' v-model='dataToView.priority'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='完成时限：' prop='completeTime'>
                                    <div v-if="mode === 'view'">{{renderViewDate( dataToView.completeTime) }}</div>
                                    <DatePicker v-else class="query-form-el" placeholder="请选择完成时限" v-model='dataToView.completeTime' ></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='工作措施：' prop='workingMeasures'>
                                    <div v-if="mode === 'view'">{{ dataToView.workingMeasures }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写工作措施" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                           maxlength="255" show-word-limit v-model='dataToView.workingMeasures'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='涉及企业工作内容：' prop='involveTasks'>
                                    <div v-if="mode === 'view'">{{ dataToView.involveTasks }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写涉及企业工作内容" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                           maxlength="255" show-word-limit v-model='dataToView.involveTasks'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='工作（整改）方案计划：' prop='workRectificationPlan'>
                                    <div v-if="mode === 'view'">{{ dataToView.workRectificationPlan }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写工作（整改）方案计划" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                           maxlength="255" show-word-limit v-model='dataToView.workRectificationPlan'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='责任人：' prop='personLiable'>
                                    <div v-if="mode === 'view'">{{ dataToView.personLiable }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写责任人" type='text' v-model='dataToView.personLiable'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='联系方式：' prop='telphone'>
                                    <div v-if="mode === 'view'">{{ dataToView.telphone }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写联系方式" type='text' v-model='dataToView.telphone'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='实际完成时间：' prop='realCompleteTime'>
                                    <div v-if="mode === 'view'">{{renderViewDate( dataToView.realCompleteTime) }}</div>
                                    <DatePicker v-else class="query-form-el" placeholder="请选择完成时限" v-model='dataToView.realCompleteTime'
                                               :clearable="false" :options="{disabledDate(date) {return date && date.valueOf() > new Date();}}"></DatePicker>
                                </FormItem>
                            </Col>
                            <Col span="11">
                            </Col>
                        </Row>
                        <Tabs value="month1">
                            <TabPane label="一月" name="month1" v-if="monthDisabled(0)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month1'>
                                            <div v-if="mode === 'view'">{{ dataToView.month1 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写一月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month1'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="二月" name="month2" v-if="monthDisabled(1)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month2'>
                                            <div v-if="mode === 'view'">{{ dataToView.month2 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写二月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month2'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="三月" name="month3" v-if="monthDisabled(2)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month3'>
                                            <div v-if="mode === 'view'">{{ dataToView.month3 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写三月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month3'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="四月" name="month4" v-if="monthDisabled(3)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month4'>
                                            <div v-if="mode === 'view'">{{ dataToView.month4 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写四月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month4'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="五月" name="month5" v-if="monthDisabled(4)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month5'>
                                            <div v-if="mode === 'view'">{{ dataToView.month5 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写五月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month5'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="六月" name="month6" v-if="monthDisabled(5)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month6'>
                                            <div v-if="mode === 'view'">{{ dataToView.month6 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写六月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month6'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="七月" name="month7" v-if="monthDisabled(6)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month7'>
                                            <div v-if="mode === 'view'">{{ dataToView.month7 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写七月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month7'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="八月" name="month8" v-if="monthDisabled(7)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month8'>
                                            <div v-if="mode === 'view'">{{ dataToView.month8 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写八月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month8'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="九月" name="month9" v-if="monthDisabled(8)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month9'>
                                            <div v-if="mode === 'view'">{{ dataToView.month9 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写九月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month9'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="十月" name="month10" v-if="monthDisabled(9)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month10'>
                                            <div v-if="mode === 'view'">{{ dataToView.month10 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写十月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month10'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="十一月" name="month11" v-if="monthDisabled(10)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month11'>
                                            <div v-if="mode === 'view'">{{ dataToView.month11 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写十一月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month11'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane label="十二月" name="month12" v-if="monthDisabled(11)">
                                <Row type="flex" justify="space-around" class="code-row-bg">
                                    <Col span="23">
                                        <FormItem label='进展情况：' prop='month12'>
                                            <div v-if="mode === 'view'">{{ dataToView.month12 }}</div>
                                            <Input v-else class='query-form-el' placeholder="请填写十二月进展情况" type='textarea' :autosize="{minRows:2,maxRows:5}"
                                                   maxlength="500" show-word-limit v-model='dataToView.month12'></Input>
                                        </FormItem>
                                    </Col>
                                </Row>
                            </TabPane>
                        </Tabs>

                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='填报人：' prop='createUserName'>
                                    <div v-if="mode === 'view'">{{ dataToView.createUserName }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写填报人" type='text' readonly
                                           v-model='dataToView.createUserName'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='填报时间：' prop='createDate'>
                                    <div v-if="mode === 'view'">{{ renderViewDate(dataToView.createDate) }}</div>
                                    <DatePicker v-else class="query-form-el" placeholder="请选择填报时间" readonly
                                                v-model='dataToView.createDate'></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>

                    </Form>
                </Col>
            </Row>
            <div slot="footer">
                <Button v-if="mode != 'view'" type="primary" class='ivu-btn-save' @click="submit('dialogForm')">确定
                </Button>
                <Button v-if="mode != 'view'" type="primary" class='ivu-btn-cancel' @click="handleCancel">取消</Button>
                <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
            </div>
        </Modal>

    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    import {formatDate} from '@/tools/index'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    import {sessionStorage, cookie} from '@/common/cacheUtils.js';

    export default {
        components: {cascaderDom},
        data() {
            return {
                ...this.createCommonDataField(),
                imgUrl: "",
                columns1: [
                    {title: '序号', width: 70, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    { key:'state',title: '更新状态',  align: 'center', minWidth: 100, render: (h, params) => {
                            let state = true
							let desc = '项目已完成'
                            if (!params.row.realCompleteTime) {
                                let nowMonth = new Date().getMonth()
                                let nowYear = new Date().getFullYear()
                                let m =  params.row['month'+(nowMonth+1)]
                                if (!m && params.row.year == nowYear) {
                                    state = false
									desc = '本月未更新'
                                } else {
									desc = '本月已更新'
								}
                            }
                        return h('span',{style: {color: !state? 'red':''},}, desc );}},
                    { key:'companyName',title: '单位名称',  align: 'center', minWidth: 180, },
                    { key:'year',title: '年份',  align: 'center', minWidth: 120,  },
                    { key:'',title: '污染防治攻坚战行动计划相关要求',  align: 'center', minWidth: 120, children:[
                            { key:'planNameDesc',title: '行动计划名称',  align: 'center', minWidth: 120,  },
                            { key:'priority',title: '重点任务',  align: 'center', minWidth: 120,  },
                            { key:'workingMeasures',title: '工作措施',  align: 'center', minWidth: 120, tooltip:true },
                        ] },
                    { key:'',title: '任务分解',  align: 'center', minWidth: 120, children:[
                            { key:'involveTasks',title: '涉及企业工作内容',  align: 'center', minWidth: 120, tooltip:true },
                            { key:'workRectificationPlan',title: '工作（整改）方案计划',  align: 'center', minWidth: 120, tooltip:true },
                            { key:'completeTime',title: '完成时限',  align: 'center', minWidth: 120,  render: this.renderCellDate },
                            { key:'personLiable',title: '责任人',  align: 'center', minWidth: 120,  },
                            { key:'telphone',title: '联系方式',  align: 'center', minWidth: 120,  },
                        ] },

                    {key: 'createDate', title: '填报时间', align: 'center', minWidth: 120,render: this.renderCellDate },
                    { key:'belongOrgName',title: '所属二级集团',  align: 'center', minWidth: 120, },
                    this.getActionColumns(),
                ],
                ruleCustom: {
                    belongOrgId: [ { required: true, message: '请填写所属二级集团', trigger: 'change',}],
                    companyId: [ { required: true, message: '请填写单位名称', trigger: 'change',}],
                    yearDate: [ { required: true, message: '请填写年份', trigger: 'change',type:'date'}],
                    planName: [ { required: true, message: '请填写行动计划名称', trigger: 'change',}],
                    priority: [ { required: true, message: '请填写重点任务', trigger: 'change',}],
                    workingMeasures: [ { required: true, message: '请填写工作措施', trigger: 'change',}],
                    involveTasks: [ { required: true, message: '请填写涉及企业工作内容', trigger: 'change',}],
                    workRectificationPlan: [ { required: true, message: '请填写工作（整改）方案计划', trigger: 'change',}],
                    completeTime: [ { required: true, message: '请填写完成时限', trigger: 'change',type:'date'}],
                    // realCompleteTime: [ { required: true, message: '请填写实际完成时间', trigger: 'change',type:'date'}],
                    personLiable: [ { required: true, message: '请填写责任人', trigger: 'change',}],
                    // month1: [ { required: true, message: '请填写一月', trigger: 'change',}],
                    // month2: [ { required: true, message: '请填写二月', trigger: 'change',}],
                    // month3: [ { required: true, message: '请填写三月', trigger: 'change',}],
                    // month4: [ { required: true, message: '请填写四月', trigger: 'change',}],
                    // month5: [ { required: true, message: '请填写五月', trigger: 'change',}],
                    // month6: [ { required: true, message: '请填写六月', trigger: 'change',}],
                    // month7: [ { required: true, message: '请填写七月', trigger: 'change',}],
                    // month8: [ { required: true, message: '请填写八月', trigger: 'change',}],
                    // month9: [ { required: true, message: '请填写九月', trigger: 'change',}],
                    // month10: [ { required: true, message: '请填写十月', trigger: 'change',}],
                    // month11: [ { required: true, message: '请填写十一月', trigger: 'change',}],
                    // month12: [ { required: true, message: '请填写十二月', trigger: 'change',}],

                    createUserName: [{required: true, message: '请填写填报人', trigger: 'change',}],
                    createDate: [{required: true, message: '请填写填报时间', trigger: 'change', type: 'date'}],
                    telphone: [{
                        validator: (rule, value, callback) => {
                            if (!(/^1[23456789]\d{9}$/.test(this.dataToView.telphone))) {
                                callback(' ');
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'blur'
                    }],
                    idFiles: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.idFiles.length < 1) {
                                callback('附件必须上传')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }]
                },
                tableHeight: 10,
                dictMap: {},
                punishment: false,
                penaltyAmount: true,
                // api
                queryUrl: Api.queryEnTable.replace('{{table}}', 'PollutionControlBattle'),
                exportUrl: Api.exportEnTable.replace('{{table}}', 'PollutionControlBattle'),
                deleteUrl: Api.deleteEnTable.replace('{{table}}', 'PollutionControlBattle'),
                getUrl: Api.getEnTable.replace('{{table}}', 'PollutionControlBattle'),
                updateUrl: Api.updateEnTable.replace('{{table}}', 'PollutionControlBattle'),
                saveUrl: Api.saveEnTable.replace('{{table}}', 'PollutionControlBattle'),
                show:true,
                currentUser: JSON.parse(sessionStorage('userId').get('userId')),

            }
        },
        async  mounted() {
            this.setTableHeight();
            this.selectSecGroupNames()
            this.query();
            await this.$http.get(Api.queryDictBycode+"env-00022",{}).then((res)=> {
                this.dictMap = {
                    "planNames": res.data.data['env-00022']
                }
            })
        },
        methods: {
            ...pageCommonFunction,
            monthDisabled(month){
                if (!this.dataToView.yearDate) {
                    return false;
                }
                let nowMonth = new Date().getMonth()
                let nowYear = new Date().getFullYear()
                let year = this.dataToView.yearDate.getFullYear()
                if (year > nowYear) {
                    return false;
                } else if(year === nowYear && nowMonth < month) {
                    return false;
                }
                return true
            },
            selectSecGroupNames(){
                this.$http.get(Api.quqeryTwoOrgInfo).then(res => {
                    this.twoLevel=res.data.data
                }).catch(e => {
                })
            },
            belongChange(value) {
                this.$set(this.dataToView,'belongOrgId',value.value)
                this.$set(this.dataToView,'belongOrgName',value.label)
                this.dataToView.companyId = null
                this.dataToView.companyName = null
                this.$refs.orgCascader.resetCurrentOrg();
                this.show = false;
                setTimeout(() => {
                    this.show = true
                }, 0)
            },
            async beforeEditDialogOpen(data) {
                data.row.yearDate = new Date(data.row.year + '-01-01');
            },
            async beforeViewDialogOpen(data) {
                data.row.yearDate = new Date(data.row.year + '-01-01');
            },
            deleteData(params) {
                this.deleteDateAjax(params);
            },
            query() {
                // if(this.dataToQuery.eventTypeIdsArrays) {
                //     this.dataToQuery.eventTypeIds = this.arrayToInFormat(this.dataToQuery.eventTypeIdsArrays)
                // }
                // this.dataToQuery.orgId = this.currentUser.companyId;
                this.queryAjax();
            },

            submit(name) {
                this.submitAjax(name);
            },
            createEmptyDataToAdd() {
                return {
                    createDate: new Date(),
                    createUserId: this.currentUser.userId,
                    createUserName: this.currentUser.userName,
                    productionNum: null,
                    storageNum: null,
                    disposalNum: null,
                    id: this.get_uuid(),
                    yearDate: new Date(),
                    year: new Date().getFullYear().toString(),
                    idFiles: [],
                }
            },
            async afterDataToViewInit() {
                // await this.getFiles1('id','pollutionControlBattle');
            },
        },
        watch: {},
    }
</script>

<style lang='css' scoped>
    .ivu-form-item {
        padding-right: 20px;
    }

    .query-form-el, .ivu-date-picker, .ivu-input-wrapper {
        width: 100%;
    }

</style>